﻿using System;
using System.IO;

namespace _09.DeleteOddLines
{
    class DeleteOddLines
    {
        static void CreateFileWithNumberRange(int start, int end, string fileName)
        {
            if (start > end)
            {
                var temp = start;
                start = end;
                end = temp;
            }

            StreamWriter streamWriter = new StreamWriter(fileName);
            using (streamWriter)
            {
                for (int i = start; i <= end; i++)
                {
                    streamWriter.WriteLine(i);
                }
            }
        }
        static void Main()
        {
            string fileName = "Text.txt";
            CreateFileWithNumberRange(1, 100, fileName);
            string text = "";

            using (StreamReader reader = new StreamReader(fileName))
            {
                string line = reader.ReadLine();
                int lineCount = 0;
                while (line != null)
                {
                    lineCount++;
                    if (lineCount % 2 == 1)
                    {
                        text += line +"\r\n";
                    }
                    line = reader.ReadLine();
                }
            }

            using (StreamWriter writer = new StreamWriter(fileName))
            {
                writer.Write(text);
            }
        }
    }
}
